import 'package:flutter/material.dart';
import 'package:flutter_live/common/redux/live_state.dart';
import 'package:flutter_live/views/categorizes/categorizes.dart';
import 'package:flutter_live/views/home/home_page.dart';
import 'package:flutter_live/views/login/login.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:redux/redux.dart';

void main() {

  runApp(MyApp());
}


class MyApp extends StatelessWidget {
  // This widget is the root of your application.

  /// 创建Store，引用 LiveState 中的 appReducer 实现 Reducer 方法
  /// initialState 初始化 State
  final store = new Store<LiveState>(
    appReducer,

    ///初始化数据
    initialState: new LiveState(  locale: Locale('zh', 'CH')),
  );


  @override
  Widget build(BuildContext context) {
    return StoreProvider(
      store: store,
      child: StoreBuilder<LiveState>(builder: (context, store) {
        return MaterialApp(
          title: 'Flutter Live',
          theme: ThemeData(
            brightness: Brightness.light,
            primaryColor: Colors.white,
            accentColor: Colors.pink[200],
          ),
          initialRoute: '/',
          routes: {
            '/': (context) => HomePage(),
            '/login': (context) => Login(),
            '/categorizes': (context) => Categorizes(),
          },
        );
      }),
    );

  }
}
